<?php

namespace pay\modules\backend\models;

use Yii;

/**
 * This is the model class for table "pay_sys_log".
 *
 * @property string $log_id
 * @property int $user_id 用户ID
 * @property string $username 用户名
 * @property string $login_add 登录地点
 * @property string $login_ip 登录ip
 * @property string $content 日志内容
 * @property string $operate_time 操作时间
 */
class SysLog extends \yii\db\ActiveRecord
{
    /**
     * {@inheritdoc}
     */
    public static function tableName()
    {
        return 'pay_sys_log';
    }

    /**
     * {@inheritdoc}
     */
    public function rules()
    {
        return [
            [['user_id'], 'integer'],
            [['operate_time'], 'safe'],
            [['username','login_ip'], 'string', 'max' => 20],
            [['login_add'], 'string', 'max' => 80],
            [['content'], 'string', 'max' => 300],
        ];
    }

    /**
     * {@inheritdoc}
     */
    public function attributeLabels()
    {
        return [
            'log_id' => 'Log ID',
            'user_id' => 'User ID',
            'username' => 'Username',
            'login_add' => 'Login Add',
            'login_ip' => 'Login Ip',
            'content' => 'Content',
            'operate_time' => 'Operate Time',
        ];
    }


    public function addInfo($data)
    {
        if ($this->load($data) and $this->validate()){
            if ($this->save(0)){
                return true;
            }
        }
        return false;
    }
}
